<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.dir(document);
        // 1.保存cookie
        // document.cookie = 'username=momoko';
        // document.cookie = 'anhao=zhimakaimen';
        console.dir(document);
        // 2.过期时间
        var passDate = new Date();
        console.log(passDate.getDate());
        // 7天后过期
        passDate.setDate(passDate.getDate() + 7);
        console.log(passDate);

        document.cookie = 'username=momoko;expires=' + passDate;
    </script>
</body>

</html>